package fast_slow_pointers;

public class MoveZeros {

    /**
     * 去除数组中的所有0
     * @param nums
     */
    public void movezeros(int[] nums) {
        int fast = 0, slow = 0;
        while (fast < nums.length) {
            if (nums[fast] != 0) {
                nums[slow] = nums[fast];
                slow++;
            }

            fast++;
        }

        for (int i = slow; i < nums.length; i++) {
            nums[i] = 0;
        }
    }
}

